package com.china.school.Pointcut的12种用法;

import com.china.school.pojo.User;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;


@Aspect
@ComponentScan({"com.china.school"}) //<context:component-scan base-package="xx"/>
@EnableAspectJAutoProxy
public class AArgsTest {


    /**

     */
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AArgsTest.class);
        User user = ctx.getBean(User.class);
        user.show1("2024-12-12","我要去西藏","旅游");
        user.show2("2024-12-12","我要去西藏","旅游");
        user.show3("2024-12-12","我要去西藏","旅游");
        user.doSomeThing("2024-12-12 我要去西藏 旅游");

    }



    @Before("@args(com.china.school.MyAnno,*,..)")
    public void before(){
        System.out.println("------before---------");
    }

    @After("@args(com.china.school.MyAnno)")
    public void after(){
        System.out.println("------before---------");
    }




    @Around("@args(..,*,com.china.school.MyAnno)")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("------around---前------" + joinPoint.getClass());

        if(joinPoint.getArgs().length == 0){

            joinPoint.proceed( );
        }else {
            joinPoint.proceed(  );

        }
        System.out.println("------around-----后----" + joinPoint.getClass());

    }







}
